package com.kcwx.generator.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kcwx.common.annotation.DataSource;
import com.kcwx.common.enums.DataSourceType;
import com.kcwx.generator.domain.GenTableColumn;
import com.kcwx.generator.mapper.GenTableColumnMysqlMapper;
import com.kcwx.generator.mapper.GenTableColumnSqlServerMapper;

/**
 * 业务字段 服务层实现
 * 
 */
@Service
public class GenTableColumnServiceImpl implements IGenTableColumnService {
	@Autowired
	private GenTableColumnSqlServerMapper genTableColumnSqlServerMapper;

	@Autowired
	private GenTableColumnMysqlMapper genTableColumnMysqlMapper;

	@Override
	@DataSource(DataSourceType.GENERATOR)
	public List<GenTableColumn> selectDbTableColumnsByName(String database, String tableName) {
		switch (database) {
		case "sqlserver":
			return genTableColumnSqlServerMapper.selectDbTableColumnsByName(tableName);
		case "mysql":
			return genTableColumnMysqlMapper.selectDbTableColumnsByName(tableName);
		default:
			return genTableColumnSqlServerMapper.selectDbTableColumnsByName(tableName);
		}
	}
}
